package com.cxm.support.controller;


import com.cxm.support.entity.Chart;
import com.cxm.support.entity.Comment;
import com.cxm.support.entity.User;
import com.cxm.support.service.CommentService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDate;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cxm
 * @since 2022-06-06
 */
@Controller
@RequestMapping("/support")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @PostMapping("/commentlistadd")
    @ResponseBody
    public String commentlistadd(Comment comment) {

        Subject subject= SecurityUtils.getSubject();
        User user = (User) subject.getSession().getAttribute("user");
        LocalDate date = LocalDate.now();
        comment.setAuthor(user.getUsername());
        commentService.save(comment);


        return null;
    }

}

